Skip to content

WIP: adds option to partition from an existing binary coloring file#117

Open
ecoon wants to merge 4 commits intoMeshToolkit:masterfrom
ecoon:ecoon/distribute_from_file
Open

WIP: adds option to partition from an existing binary coloring file#117
ecoon wants to merge 4 commits intoMeshToolkit:masterfrom
ecoon:ecoon/distribute_from_file

Conversation

@ecoon
Copy link
Collaborator

@ecoon ecoon commented Jan 5, 2021

@raovgarimella I'd like to add a capability to partition based on a user-provided file. The attached pull request works in the one simple file example I've tried. It is a bit weird because there is no way of providing MESH_Get_Partition with a filename option, so currently the filename is hard-coded as "./coloring.bin".

The file format is simply a bunch of ints, one per region, defining the color (from 0 to NPROC).

The implementation simply mallocs parts, then reads it from file in a single block. To write this file, one must write a C binary file, which can be done in C or in python, e.g. for a four-cell problem:

import struct
with open('coloring.bin', 'wb') as fid:
    for i in [0,0,1,1]:
        fid.write(struct.pack('i', i))

At first glance this worked for me, and allowed meshconvert to partition this file as requested (using partition-method=3).

@ecoon
Copy link
Collaborator Author

ecoon commented Sep 4, 2021

@raovgarimella Any thoughts on this? I'm going to add it as a patch in Amanzi for now as I need it now, but it would be nice to get this included at some point.

@raovgarimella
Copy link
Contributor

Sounds good. It's a good idea for MSTK as well. Perhaps a trivial student project?

@ecoon
Copy link
Collaborator Author

ecoon commented Sep 7, 2021

This is a pull request -- it's implemented here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants